package com.enumdemo.kind.demo2;

import java.util.Random;

public enum Meal2 {

	APPETIZER(Food.Appetizer.class), MAINCOURSE(Food.MainCourse.class), DESSERT(
			Food.Dessert.class), COFFEE(Food.Coffee.class);

	private Food[] values;

	// 通过getEnumConstants()获取某个Food子类的所有enum实例
	private Meal2(Class<? extends Food> kind) {
		values = kind.getEnumConstants();
	}

	public interface Food {

		enum Appetizer implements Food {
			SALAD, SOUP, SPRING_ROLLS
		}

		enum MainCourse implements Food {
			LASAGNE, BURRITO, PAD_THAI, LENTILS, HUMMOUS, VINDALOO
		}

		enum Dessert implements Food {
			TIRAMISU, GELATO, FRUIT, CREME_CARAMEL
		}

		enum Coffee implements Food {
			BLACK_COFFEE, DECAF_COFFEE, ESPRESSO, LATTE, CAPPUCCINO, TEA, HERB_TEA
		}

	}

	Random rand = new Random(47);

	public Food randomSelectin() {
		return values[rand.nextInt(4)];
	}

	public static void main(String[] args) {
		for (int i = 0; i < 5; i++) {
			for (Meal2 meal : Meal2.values()) {
				Food food = meal.randomSelectin();
				System.out.println(food);
			}
			System.out.println("=========================");
		}
	}

}
